<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改药品管理（旧）')" />
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: summernote-css"/>
    <th:block th:include="include :: jquery-smartwizard-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
    <th:block th:include="include :: summernote-css"/>

</head>
<script src="../static/js/xm-select.js" th:src="@{/js/xm-select.js}"></script>

<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-oldDrug-edit" th:object="${oldDrug}">
            <ul class="nav nav-tabs">
                <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true"> 基本信息</a>
                </li>
                <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">其他信息</a>
                </li>
                <li class=""><a data-toggle="tab" href="#tab-3" aria-expanded="false">规格信息</a>
                </li>
            </ul>
            <div class="tab-content">
                <input name="id" th:field="*{id}" type="hidden">

                <div id="tab-1" class="tab-pane active" style="padding: 20px">
                    <div class="form-group">
                        <div class="col-sm-6">
                            <label class="col-sm-2 control-label">名称</label>
                            <div class="col-sm-10">
                                <input name="name" th:field="*{name}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <label class="col-sm-2 control-label">别名</label>
                            <div class="col-sm-10">
                                <input name="alias" th:field="*{alias}" class="form-control" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-sm-12">
                            <label class="col-sm-1 control-label">选择疾病</label>
                            <div class="col-sm-11">
                                <div id="selectDemo"></div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-12">
                            <label class="col-sm-1 control-label">主图</label>
                            <div class="col-sm-11">
                                <input name="icon" th:value="*{icon}" type="hidden" required>
                                <div class="file-loading">
                                    <input class="form-control file-upload"  id="icon" name="file" type="file">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-12">
                            <label class="col-sm-1 control-label">简介</label>
                            <div class="col-sm-11">
                                <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-6">
                            <label class="col-sm-2 control-label">厂家</label>
                            <div class="col-sm-10">
                                <select name="manuId" class="form-control m-b" th:field="*{manuId}"
                                        th:with="type=${@dict.getType('drug_factory')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                            th:value="${dict.dictValue}"></option>
                                </select>
                            </div>
                        </div>

                        <div class="col-sm-6">
                            <label class="col-sm-2 control-label">有效期</label>
                            <div class="col-sm-10">
                                <input name="periodOfValidity" th:field="*{periodOfValidity}" class="form-control" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-6">
                            <label class="col-sm-2 control-label">准批文号</label>
                            <div class="col-sm-10">
                                <input name="quasiApprovalNo" th:field="*{quasiApprovalNo}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <label class="col-sm-2 control-label">剂型</label>
                            <div class="col-sm-10">
                                <select name="dosageId" class="form-control m-b" th:field="*{dosageId}"
                                        th:with="type=${@dict.getType('jx_type')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                            th:value="${dict.dictValue}"></option>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-6">
                            <label class="col-sm-2 control-label">是否处方药</label>
                            <div class="col-sm-10">
                                <select name="isPrescription" class="form-control m-b" th:field="*{isPrescription}"
                                        th:with="type=${@dict.getType('sys_yes_no')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                            th:value="${dict.dictValue}"></option>
                                </select>
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <label class="col-sm-2 control-label">排序</label>
                            <div class="col-sm-10">
                                <input name="sort" th:field="*{sort}" class="form-control" type="text">
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-12">
                            <label class="col-sm-1 control-label">储存条件</label>
                            <div class="col-sm-11">
                                <textarea name="storagecondition" class="form-control">[[*{storagecondition}]]</textarea>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-6">
                            <label class="col-sm-2 control-label">性状</label>
                            <div class="col-sm-10">
                                <textarea name="xingzhuang" class="form-control">[[*{xingzhuang}]]</textarea>
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <label class="col-sm-2 control-label">适用人群</label>
                            <div class="col-sm-10">
                                <textarea name="suitableforthecroud" class="form-control">[[*{suitableforthecroud}]]</textarea>
                            </div>
                        </div>
                    </div>



                    <div class="form-group">
                        <div class="col-sm-12">
                            <label class="col-sm-1 control-label">温馨提示</label>
                            <div class="col-sm-11">
                                <textarea name="warmPrompt" class="form-control">[[*{warmPrompt}]]</textarea>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-12">
                            <label class="col-sm-1 control-label">参考资料</label>
                            <div class="col-sm-11">
                                <textarea name="referenceMaterial" class="form-control">[[*{referenceMaterial}]]</textarea>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-12">
                            <label class="col-sm-1 control-label">信息来源</label>
                            <div class="col-sm-11">
                                <textarea name="informationSources" class="form-control">[[*{informationSources}]]</textarea>
                            </div>
                        </div>
                    </div>
                </div>
                <div id="tab-2" class="tab-pane " style="padding: 20px">
                    <div class="form-group">
                        <div class="col-sm-12">
                            <label class="col-sm-1 control-label">成分</label>
                            <div class="col-sm-11">
                                <input type="hidden" class="form-control" required>
                                <script id="ingredient" name="ingredient" type="text/plain"></script>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-12">
                            <label class="col-sm-1 control-label">用法用量</label>
                            <div class="col-sm-11">
                                <input type="hidden" class="form-control" required>
                                <script id="usageanddosage" name="usageanddosage" type="text/plain"></script>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-12">
                            <label class="col-sm-1 control-label">副作用</label>
                            <div class="col-sm-11">
                                <input type="hidden" class="form-control" required>
                                <script id="untoward" name="untoward" type="text/plain"></script>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-12">
                            <label class="col-sm-1 control-label">禁忌</label>
                            <div class="col-sm-11">
                                <input type="hidden" class="form-control" required>
                                <script id="taboos" name="taboos" type="text/plain"></script>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-12">
                            <label class="col-sm-1 control-label">注意事项</label>
                            <div class="col-sm-11">
                                <input type="hidden" class="form-control" required>
                                <script id="announcements" name="announcements" type="text/plain"></script>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-12">
                            <label class="col-sm-1 control-label">适应症</label>
                            <div class="col-sm-11">
                                <input type="hidden" class="form-control" required>
                                <script id="adaptationdisease" name="adaptationdisease" type="text/plain"></script>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-12">
                            <label class="col-sm-1 control-label">药物相互作用</label>
                            <div class="col-sm-11">
                                <input type="hidden" class="form-control" required>
                                <script id="mutual" name="mutual" type="text/plain"></script>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-12">
                            <label class="col-sm-1 control-label">商品详情</label>
                            <div class="col-sm-11">
                                <input type="hidden" class="form-control" required>
                                <script id="detail" name="detail" type="text/plain"></script>
                            </div>
                        </div>
                    </div>

                </div>
                <div id="tab-3" class="tab-pane " style="padding: 20px">
                    <a class="btn btn-chongzhi btn-rounded mr16 mb20 btn-sm" onclick="addSpeDiv()">新增规格</a>

                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer"/>
    <th:block th:include="include :: datetimepicker-js"/>
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <th:block th:include="include :: summernote-js"/>
    <th:block th:include="include :: jquery-smartwizard-js"/>
    <th:block th:include="include :: select2-js"/>
    <th:block th:include="include :: bootstrap-select-js"/>
    <th:block th:include="include :: summernote-js"/>
    <script src="/ueditor/ueditor.config.js" type="text/javascript" charSet="utf-8"></script>
    <script src="/ueditor/ueditor.all.js" type="text/javascript" charSet="utf-8"></script>
    <script src="/ueditor/lang/zh-cn/zh-cn.js" type="text/javascript" charSet="utf-8"></script>
    <script th:inline="javascript">
        let oldDrugSpecificationList = [[${oldDrug}]].oldDrugSpecificationList;
        let diseaseList = [[${oldDrug}]].diseaseList;
        let i = 0;
        var selectData = [];
        var backdis = [];
        var disarr = [];
        var alldis=[]
        var prefix = ctx + "ydz/oldDrug"
        $("#form-oldDrug-add").validate({
            focusCleanup: true
        });
        $(document).ready(function () {
            diseaseList.forEach(item=>{
                let obj = {}
                obj.name = item.name
                obj.diseaseId =item.diseaseId
                obj.pid = item.pid
                disarr.push(obj)
                console.log(disarr)
                backdis.push(item.diseaseId.toString())
            })
            parent.$('body').find('.layui-layer-max:not(.layui-layer-maxmin)').click()
            $.ajax({
                url: "/api/common/selectAnyDisease",
                type: "get",
                success: res => {
                    alldis = res.data
                    for (let i = 0; i < alldis.length; i++){
                        let val = {}
                        val.name = alldis[i].name
                        val.diseaseId = alldis[i].id
                        val.pid = alldis[i].pid
                        selectData.push(val)
                    }
                    initXmSelect()
                }
            })
        })

        function initXmSelect(){
            xmSelect.render({
                el: '#selectDemo',
                checkbox: true,
                repeat: false,
                autoRow: true,
                filterable: true,
                prop: {name: 'name', value: 'diseaseId',pid:'pid'},
                initValue: backdis,//回显
                height: '200px',
                tips: '请选择',
                tree: {
                    show: true,
                    showFolderIcon: true,
                    showLine: true,
                    indent: 20,
                    expandedKeys: [-3],
                    strict: false,
                },
                data: function () {
                    return selectData
                },
                on: function (data) {
                    arr = data.arr;//arr:  当前多选已选中的数据
                    disarr = data.arr
                },
            });
        }
        oldDrugSpecificationList.forEach(function (item,index) {
            //计算规格长度，添加时从长度开始添加
            i++;
            var spName = "spName"+index;
            var spjiage = "jiage"+index;
            var spIcon = "spIcon"+index;
            var name = item.name;
            var jiage = item.jiage;
            var icon = item.icon;
            var html= "<div class='spDiv'>"
                +"<div class='form-group'>"
                +"<div class='col-sm-6'>"
                +"<label class='col-sm-2 control-label '>规格</label>"
                +"<div class='col-sm-10'>"
                +"<input name='"+spName+"' value='"+name+"' class='form-control' type='text'>"
                +"</div>"
                +"</div>"
                +"<div class='col-sm-6'>"
                +"<label class='col-sm-2 control-label'>实际价格</label>"
                +"<div class='col-sm-10'>"
                +"<input name='"+spjiage+"' value='"+jiage+"' class='form-control' type='text'>"
                +"</div>"
                +"</div>"
                +"</div>"
                +"<div class='form-group'>"
                +"<div class='col-sm-12'>"
                +"<label class='col-sm-1 control-label'>相册</label>"
                +"<div class='col-sm-11'>"
                +"<input type='hidden' name='"+spIcon+"' value='"+icon+"'>"
                +"<div class='file-loading'>"
                +"<input class='files-upload' id='"+spIcon+"'  name='files' type='file' multiple>"
                +"</div>"
                +"</div>"
                +"</div>"
                +"</div>"
                +"</div>"
            $("#tab-3").append(html);

        });
        var jsDrugimgpaths = []
        $(".files-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            let initialPreview = []
            if (val) {
                initialPreview = val.split(',')
            }
            //回显的图片进行同数组结构存储
            let oldimgsarr = []
            for (var i = 0; i < initialPreview.length;i++){
                let data={
                    name: "oldimg",
                    url: initialPreview[i]
                }
                oldimgsarr.push(data)
            }
            jsDrugimgpaths = oldimgsarr
            $(this).fileinput({
                uploadUrl: ctx + 'common/uploads',
                initialPreview: initialPreview,
                allowedFileTypes: ['image'],
                maxFileCount: 5,
                uploadAsync: false,
                autoReplace: false,
                initialPreviewAsData: true,
                overwriteInitial:false
            }).on('filebatchuploadsuccess', function (event, data, previewId, index) {
                jsDrugimgpathsFun(data.response.fileNames, data.response.originalFilenames)
                silderurls(event.currentTarget.id)
            }).on('fileuploaded', function (event, data, previewId, index) {
                jsDrugimgpathsFun(data.response.fileNames, data.response.originalFilenames)
                silderurls(event.currentTarget.id)
            }).on('filesuccessremove', function (event, id, index) {
                //小移除按钮
                let filename = $(this).parents('.form-group').find(`div[id='${id}']`).data('filename')
                for (let i in jsDrugimgpaths) {
                    if (jsDrugimgpaths[i].name == filename) {
                        jsDrugimgpaths.splice(i, 1)
                    }
                }
                silderurls(event.currentTarget.id)
            }).on('fileremoved', function (event, id, index) {
                let numberindex = index[index.length - 1]
                jsDrugimgpaths.splice(numberindex,1)
                silderurls(event.currentTarget.id)
            }).on('fileclear', function (event, id, index) {
                jsDrugimgpaths = []

                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
        /*拼接保存轮播图的内容*/
        function jsDrugimgpathsFun(fileNames, originalFilenames) {
            let fileNamesArr = fileNames.split(',')
            let originalFilenamesArr = originalFilenames.split(',')
            for (let i in fileNamesArr) {
                jsDrugimgpaths.push({
                    name: originalFilenamesArr[i],
                    url: fileNamesArr[i]
                })
            }
        }
        //对相应的标签进行赋值
        function silderurls(id) {
            let slides = []
            for (let i in jsDrugimgpaths) {
                slides.push(jsDrugimgpaths[i].url)
            }
            $("input[name='" + id + "']").val(slides.join(','))
        }

        function submitHandler() {

            var speArr=[]
            $('.spDiv').each(function(index){
                var obj = {}
                obj.name = $('input[name=' + 'spName' + index + ']').val();
                obj.jiage =  $('input[name=' + 'jiage' + index + ']').val();
                obj.icon  = $('input[name=' + 'spIcon' + index + ']').val();
                speArr.push(obj);
            })

            if ($.validate.form()) {
                var jsons = {};
                let formData = $('#form-oldDrug-edit').serializeArray();
                $.each(formData, function (k, v) {
                    jsons[v.name] = v.value;
                });
                jsons["oldDrugSpecificationList"] = speArr;
                jsons["diseaseList"] = disarr;
                var value = JSON.stringify(jsons)
                console.log("数据打印：",value)
                save(prefix + "/edit", value);
            }
        }

        function save(url, data, callback) {
            var config = {
                url: url,
                type: "post",
                dataType: "json",
                data: data,
                headers: {
                    'Content-Type': 'application/json;charset=utf8'
                },
                beforeSend: function () {
                    $.modal.loading("正在处理中，请稍候...");
                    $.modal.disable();
                },
                success: function (result) {
                    if (typeof callback == "function") {
                        callback(result);
                    }
                    $.operate.successCallback(result);
                }
            };
            $.ajax(config)
        }


        function addSpeDiv() {
            var spName = "spName"+i;
            var jiage = "jiage"+i;
            var spIcon = "spIcon"+i;
            var html= "<div class='spDiv'>"
                +"<div class='form-group'>"
                +"<div class='col-sm-6'>"
                +"<label class='col-sm-2 control-label '>规格</label>"
                +"<div class='col-sm-10'>"
                +"<input name='"+spName+"' class='form-control' type='text'>"
                +"</div>"
                +"</div>"
                +"<div class='col-sm-6'>"
                +"<label class='col-sm-2 control-label'>实际价格</label>"
                +"<div class='col-sm-10'>"
                +"<input name='"+jiage+"' class='form-control' type='text'>"
                +"</div>"
                +"</div>"
                +"</div>"
                +"<div class='form-group'>"
                +"<div class='col-sm-12'>"
                +"<label class='col-sm-1 control-label'>相册</label>"
                +"<div class='col-sm-11'>"
                +"<input type='hidden' name='"+spIcon+"'>"
                +"<div class='file-loading'>"
                +"<input class='files-upload' id='"+spIcon+"' name='files' type='file' multiple>"
                +"</div>"
                +"</div>"
                +"</div>"
                +"</div>"
                +"</div>"
            $("#tab-3").append(html);
            i++;
            // 多图上传
            $(".files-upload").fileinput({
                uploadUrl: ctx + 'common/uploads',
                allowedFileTypes: ['image'],
                maxFileCount: 5,
                autoReplace: false,
                uploadAsync: false
            }).on('filebatchuploadsuccess', function (event, data, previewId, index) {
                var rsp = data.response;
                let val = $("input[name='" + event.currentTarget.id + "']").val()
                if (val) {
                    val += ','
                }
                console.log(event.currentTarget,event.currentTarget);
                $("input[name='" + event.currentTarget.id + "']").val(val + rsp.fileNames)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
        }



        //富文本
        UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
        UE.Editor.prototype.getActionUrl = function (action) {
            if (action == 'uploadimage' || action == 'uploadscrawl') {
                return '/common/upload';
            } else {
                return this._bkGetActionUrl.call(this, action);
            }
        }
        var ingredientUe = UE.getEditor('ingredient', {
            autoHeightEnabled: false,//是否自动长高
            autoFloatEnabled: true,//是否保持toolbar的位置不动
            scaleEnabled: true,//是否可以拉伸长高
            initialFrameWidth: 'auto',//初始化编辑器宽度
            initialFrameHeight: 300,//初始化编辑器高度
        });
        ingredientUe.ready(function () {
            ingredientUe.execCommand("insertHtml", [[${oldDrug}]].ingredient);//富文本回显
        })
        var usageanddosageUe = UE.getEditor('usageanddosage', {
            autoHeightEnabled: false,//是否自动长高
            autoFloatEnabled: true,//是否保持toolbar的位置不动
            scaleEnabled: true,//是否可以拉伸长高
            initialFrameWidth: 'auto',//初始化编辑器宽度
            initialFrameHeight: 300,//初始化编辑器高度
        });
        usageanddosageUe.ready(function () {
            usageanddosageUe.execCommand("insertHtml", [[${oldDrug}]].usageanddosage);//富文本回显
        })
        var untowarDue = UE.getEditor('untoward', {
            autoHeightEnabled: false,//是否自动长高
            autoFloatEnabled: true,//是否保持toolbar的位置不动
            scaleEnabled: true,//是否可以拉伸长高
            initialFrameWidth: 'auto',//初始化编辑器宽度
            initialFrameHeight: 300,//初始化编辑器高度
        });
        untowarDue.ready(function () {
            untowarDue.execCommand("insertHtml", [[${oldDrug}]].untoward);//富文本回显
        })
        var taboosUe = UE.getEditor('taboos', {
            autoHeightEnabled: false,//是否自动长高
            autoFloatEnabled: true,//是否保持toolbar的位置不动
            scaleEnabled: true,//是否可以拉伸长高
            initialFrameWidth: 'auto',//初始化编辑器宽度
            initialFrameHeight: 300,//初始化编辑器高度
        });
        taboosUe.ready(function () {
            taboosUe.execCommand("insertHtml", [[${oldDrug}]].taboos);//富文本回显
        })
        var announcementsUe = UE.getEditor('announcements', {
            autoHeightEnabled: false,//是否自动长高
            autoFloatEnabled: true,//是否保持toolbar的位置不动
            scaleEnabled: true,//是否可以拉伸长高
            initialFrameWidth: 'auto',//初始化编辑器宽度
            initialFrameHeight: 300,//初始化编辑器高度
        });
        announcementsUe.ready(function () {
            announcementsUe.execCommand("insertHtml", [[${oldDrug}]].announcements);//富文本回显
        })
        var adaptationdiseaseUe = UE.getEditor('adaptationdisease', {
            autoHeightEnabled: false,//是否自动长高
            autoFloatEnabled: true,//是否保持toolbar的位置不动
            scaleEnabled: true,//是否可以拉伸长高
            initialFrameWidth: 'auto',//初始化编辑器宽度
            initialFrameHeight: 300,//初始化编辑器高度
        });
        adaptationdiseaseUe.ready(function () {
            adaptationdiseaseUe.execCommand("insertHtml", [[${oldDrug}]].adaptationdisease);//富文本回显
        })
        var mutualUe = UE.getEditor('mutual', {
            autoHeightEnabled: false,//是否自动长高
            autoFloatEnabled: true,//是否保持toolbar的位置不动
            scaleEnabled: true,//是否可以拉伸长高
            initialFrameWidth: 'auto',//初始化编辑器宽度
            initialFrameHeight: 300,//初始化编辑器高度
        });
        mutualUe.ready(function () {
            mutualUe.execCommand("insertHtml", [[${oldDrug}]].mutual);//富文本回显
        })
        var detailUe = UE.getEditor('detail', {
            autoHeightEnabled: false,//是否自动长高
            autoFloatEnabled: true,//是否保持toolbar的位置不动
            scaleEnabled: true,//是否可以拉伸长高
            initialFrameWidth: 'auto',//初始化编辑器宽度
            initialFrameHeight: 300,//初始化编辑器高度
        });
        detailUe.ready(function () {
            detailUe.execCommand("insertHtml", [[${oldDrug}]].detail);//富文本回显
        })

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            if (val==""){
                $(".file-upload").fileinput({
                    uploadUrl: ctx + 'common/upload',
                    maxFileCount: 1,
                    autoReplace: true
                }).on('fileuploaded', function (event, data, previewId, index) {
                    $("input[name='" + event.currentTarget.id + "']").val(data.response.fileName)
                }).on('fileremoved', function (event, id, index) {
                    $("input[name='" + event.currentTarget.id + "']").val('')
                })
            }else{
                $(this).fileinput({
                    'uploadUrl': ctx + 'common/upload',
                    initialPreviewAsData: true,
                    initialPreview: [val],
                    maxFileCount: 1,
                    autoReplace: true
                }).on('fileuploaded', function (event, data, previewId, index) {
                    $("input[name='" + event.currentTarget.id + "']").val(data.response.fileName)
                }).on('fileremoved', function (event, id, index) {
                    $("input[name='" + event.currentTarget.id + "']").val('')
                })
                $(this).fileinput('_initFileActions');
            }
        });

    </script>
</body>
</html>